#include "S_1_DeviceInformation_doGet.h"
#include "string.h"
#include "mi_iid_define.h"
#include "property_decoder.h"
#include "main.h"


extern uint8_t g_uNo3RegList[PBS_NO3REGSIZE];
extern uint8_t  g_uNo4RegList[PBS_NO4REGSIZE];
/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_1_1_Manufacturer_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
	property_value_new_string(&o->value,"xiaomi");
	
#else	
	
    o->value.format = PROPERTY_FORMAT_STRING;
	
	strncpy(o->value.data.string.value, "xiaomi", strlen("xiaomi"));
	
	o->value.data.string.length = strlen("xiaomi");
#endif
}

/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_1_2_Model_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
	property_value_new_string(&o->value,"xiaomi.airc.1r04r1");
#else
	
   o->value.format = PROPERTY_FORMAT_STRING;
	
	strncpy(o->value.data.string.value, "xiaomi.airc.1r04r1", strlen("xiaomi.airc.1r04r1"));
	
	o->value.data.string.length = strlen("xiaomi.airc.1r04r1");
#endif
}

/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_1_3_SerialNumber_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
	property_value_new_string(&o->value,"820841091");
#else	
	
    o->value.format = PROPERTY_FORMAT_STRING;
	
	strncpy(o->value.data.string.value, "820841091", strlen("820841091"));
	
	o->value.data.string.length = strlen("820841091");
#endif
}

/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_1_4_FirmwareRevision_doGet(property_operation_t *o)
{
#if 	PROPERTY_TYPE
	property_value_new_string(&o->value,"1.0.1.0002");
#else	
    o->value.format = PROPERTY_FORMAT_STRING;
	
	strncpy(o->value.data.string.value, "1.0.1.0002", strlen("1.0.1.0002"));
	
	o->value.data.string.length = strlen("1.0.1.0002");
#endif
}

/**
 * 格式: property_value_new_string(字符串)　
 * 取值: 字符串，没有限制取值范围
 */
static void P_1_5_SerialNo_doGet(property_operation_t *o)
{
	char str[40] = {0};
#if 	PROPERTY_TYPE
	memcpy(str,&g_uNo4RegList[0x27],20);
	property_value_new_string(&o->value,str);
#else	
    o->value.format = PROPERTY_FORMAT_STRING;
	
	strncpy(o->value.data.string.value, "hello", strlen("hello"));
	
	o->value.data.string.length = strlen("hello");
#endif
}

void S_1_DeviceInformation_doGet(property_operation_t *o)
{
    switch (o->piid)
    {
        case PIID_1_1_Manufacturer:
            P_1_1_Manufacturer_doGet(o);
            break;

        case PIID_1_2_Model:
            P_1_2_Model_doGet(o);
            break;

        case PIID_1_3_SerialNumber:
            P_1_3_SerialNumber_doGet(o);
            break;

        case PIID_1_4_FirmwareRevision:
            P_1_4_FirmwareRevision_doGet(o);
            break;

        case PIID_1_5_SerialNo:
            P_1_5_SerialNo_doGet(o);
            break;

        default:
            o->code = OPERATION_ERROR_VALUE;
            break;
    }
}
